/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package contatospro;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 *
 * @author Junnyor S2 Rafa
 */
@Entity
@Table(name = "historico_contatos", catalog = "contatospro", schema = "")
@NamedQueries({
    @NamedQuery(name = "HistoricoContatos.findAll", query = "SELECT h FROM HistoricoContatos h"),
    @NamedQuery(name = "HistoricoContatos.findByCodHistorico", query = "SELECT h FROM HistoricoContatos h WHERE h.codHistorico = :codHistorico"),
    @NamedQuery(name = "HistoricoContatos.findByCodContato", query = "SELECT h FROM HistoricoContatos h WHERE h.codContato = :codContato"),
    @NamedQuery(name = "HistoricoContatos.findByCodPessoa", query = "SELECT h FROM HistoricoContatos h WHERE h.codPessoa = :codPessoa"),
    @NamedQuery(name = "HistoricoContatos.findByDataUltimoContato", query = "SELECT h FROM HistoricoContatos h WHERE h.dataUltimoContato = :dataUltimoContato"),
    @NamedQuery(name = "HistoricoContatos.findByHoraUltimoContato", query = "SELECT h FROM HistoricoContatos h WHERE h.horaUltimoContato = :horaUltimoContato")})
public class HistoricoContatos implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "COD_HISTORICO")
    private Integer codHistorico;
    @JoinColumn(name = "COD_CONTATO",referencedColumnName="COD_CONTATO")
    @ManyToOne
    private Contatos codContato;
    @JoinColumn(name = "COD_PESSOA",referencedColumnName="COD_PESSOA")
    @ManyToOne
    private Pessoas codPessoa;
    @Lob
    @Column(name = "HISTORICO_CONVERSA")
    private String historicoConversa;
    @Column(name = "DATA_ULTIMO_CONTATO")
    @Temporal(TemporalType.DATE)
    private Date dataUltimoContato;
    @Column(name = "HORA_ULTIMO_CONTATO")
    @Temporal(TemporalType.TIME)
    private Date horaUltimoContato;

    public HistoricoContatos() {
    }

    public HistoricoContatos(Integer codHistorico) {
        this.codHistorico = codHistorico;
    }

    public HistoricoContatos(Integer codHistorico, Contatos codContato, Pessoas codPessoa) {
        this.codHistorico = codHistorico;
        this.codContato = codContato;
        this.codPessoa = codPessoa;
    }

    public Integer getCodHistorico() {
        return codHistorico;
    }

    public void setCodHistorico(Integer codHistorico) {
        Integer oldCodHistorico = this.codHistorico;
        this.codHistorico = codHistorico;
        changeSupport.firePropertyChange("codHistorico", oldCodHistorico, codHistorico);
    }

    public Contatos getCodContato() {
        return codContato;
    }

    public void setCodContato(Contatos codContato) {
        Contatos oldCodContato = this.codContato;
        this.codContato = codContato;
        changeSupport.firePropertyChange("codContato", oldCodContato, codContato);
    }

    public Pessoas getCodPessoa() {
        return codPessoa;
    }

    public void setCodPessoa(Pessoas codPessoa) {
        Pessoas oldCodPessoa = this.codPessoa;
        this.codPessoa = codPessoa;
        changeSupport.firePropertyChange("codPessoa", oldCodPessoa, codPessoa);
    }

    public String getHistoricoConversa() {
        return historicoConversa;
    }

    public void setHistoricoConversa(String historicoConversa) {
        String oldHistoricoConversa = this.historicoConversa;
        this.historicoConversa = historicoConversa;
        changeSupport.firePropertyChange("historicoConversa", oldHistoricoConversa, historicoConversa);
    }

    public Date getDataUltimoContato() {
        return dataUltimoContato;
    }

    public void setDataUltimoContato(Date dataUltimoContato) {
        Date oldDataUltimoContato = this.dataUltimoContato;
        this.dataUltimoContato = dataUltimoContato;
        changeSupport.firePropertyChange("dataUltimoContato", oldDataUltimoContato, dataUltimoContato);
    }

    public Date getHoraUltimoContato() {
        return horaUltimoContato;
    }

    public void setHoraUltimoContato(Date horaUltimoContato) {
        Date oldHoraUltimoContato = this.horaUltimoContato;
        this.horaUltimoContato = horaUltimoContato;
        changeSupport.firePropertyChange("horaUltimoContato", oldHoraUltimoContato, horaUltimoContato);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codHistorico != null ? codHistorico.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HistoricoContatos)) {
            return false;
        }
        HistoricoContatos other = (HistoricoContatos) object;
        if ((this.codHistorico == null && other.codHistorico != null) || (this.codHistorico != null && !this.codHistorico.equals(other.codHistorico))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "contatospro.HistoricoContatos[ codHistorico=" + codHistorico + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
